package net.mikoo.seals.boss.common.enums;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;

import org.apache.commons.lang.StringUtils;

@XmlType(name = "OrderStatus")
@XmlEnum
public enum OrderStatusEnum {

	WAIT_PAY("WAIT_PAY", "等待买家付款"),
	
	WAIT_REVIEW_PAY("WAIT_REVIEW_PAY", "待确认支付"),
	
	WAIT_PICKING("WAIT_PICKING", "等待配货"),
	
	WAIT_SHIP("WAIT_SHIP", "等待发货"),
	
	WAIT_RECEIVING("WAIT_RECEIVING", "等待收货"),
	
	CANCEL("CANCEL", "交易关闭"),

	SUCCESS("SUCCESS", "交易成功"),
	
	EXCEPTIONAL("EXCEPTIONAL", "订单异常")
	
;
	

	/** 枚举值 */
	private final String code;

	/** 枚举描述 */
	private final String message;

	/**
	 * 构造一个<code>ContractStatusEnum</code>枚举对象
	 * 
	 * @param code
	 * @param message
	 */
	private OrderStatusEnum(String code, String message) {
		this.code = code;
		this.message = message;
	}

	/**
	 * @return Returns the code.
	 */
	public String getCode() {
		return code;
	}

	/**
	 * @return Returns the message.
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * @return Returns the code.
	 */
	public String code() {
		return code;
	}

	/**
	 * @return Returns the message.
	 */
	public String message() {
		return message;
	}

	/**
	 * 通过枚举<code>code</code>获得枚举
	 * 
	 * @param code
	 * @return ContractStatusEnum
	 */
	public static OrderStatusEnum getByCode(String code) {
		for (OrderStatusEnum _enum : values()) {
			if (StringUtils.equals(_enum.getCode(), code)) {
				return _enum;
			}
		}
		return null;
	}

	/**
	 * 获取全部枚举
	 * 
	 * @return List<ContractStatusEnum>
	 */
	public List<OrderStatusEnum> getAllEnum() {
		List<OrderStatusEnum> list = new ArrayList<OrderStatusEnum>();
		for (OrderStatusEnum _enum : values()) {
			list.add(_enum);
		}
		return list;
	}

	/**
	 * 获取全部枚举值
	 * 
	 * @return List<String>
	 */
	public List<String> getAllEnumCode() {
		List<String> list = new ArrayList<String>();
		for (OrderStatusEnum _enum : values()) {
			list.add(_enum.code());
		}
		return list;
	}

}
